import Page
from Page import SmartHome
from Base.Base import Base
from selenium.webdriver.common.by import By


class SmartHomeXiaobaiIndexPage(Base):
    """
    小白首页

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.xiaobai_index_home_btn = (By.XPATH, SmartHome.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.xiaobai_index_back_btn = (By.XPATH, SmartHome.RESOURCE_ID.format('ivBack'))

        # 退出键
        self.xiaobai_index_quit_btn = (By.XPATH, SmartHome.RESOURCE_ID.format("btn_login_out"))

        # 列表场景的名称
        self.xiaobai_index_list_card_text = (By.XPATH, SmartHome.xiaobai_index_list_card_text.format(1))

        # 确认框确认按钮
        self.xiaobai_confirm_sure_btn = (By.XPATH, SmartHome.RESOURCE_ID.format("btn_confirm_sure"))

        # 确认框取消按钮
        self.xiaobai_confirm_cancel_btn = (By.XPATH, SmartHome.RESOURCE_ID.format("btn_confirm_cancel"))

    def get_index_list_card(self, index=1):
        """
        获取指定索引的场景标题

        :param index: 索引值
        :return:
        """
        self.xiaobai_index_list_card_text = (By.XPATH, SmartHome.xiaobai_index_list_card_text.format(index))
        return self.find_element_o(self.xiaobai_index_list_card_text)

    def click_card_list_card(self, index=1):
        """
        点击指定索引的场景

        :param index: 索引值
        :return:
        """
        self.xiaobai_index_list_card_text = (By.XPATH, SmartHome.xiaobai_index_list_card_text.format(index))
        self.click_element(self.xiaobai_index_list_card_text)

    def click_quit(self):
        """
        点击退出

        :return:
        """
        self.click_element(self.xiaobai_index_quit_btn)

    def click_confirm_sure(self):
        """
        点击确认框的确认按钮

        :return:
        """
        self.click_element(self.xiaobai_confirm_sure_btn)